import format from '@dfeidao/atom-mobile/dt/format';
import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import set from '@dfeidao/atom-mobile/local/set';
import nodejs from '@dfeidao/atom-mobile/msg/nodejs';
import render from '@dfeidao/atom-mobile/render/render';

import whoami from '../atom/whoami_getparams';
export default async function a001(fd: IFeidaoAiMobile) {
	// 初始化触发未审批
	// 获取系统参数,未登录，获取不到session报错
	const user = await whoami(fd) as {
		params: {
			teacher_name: string;
			productid: string;
			teacher_no: string;
		}
	};
	await set(fd, 'user', user);
	const start_time = new Date(new Date().toLocaleDateString()).getTime();
	const date_time = await format(start_time, 0);
	const end_time = start_time + 86399999;
	const d = await nodejs('app-after-class-review/s001', {
		filter: {
			teacher_no: user.params.teacher_no,// teacher_no JS0004
			start_time,
			end_time,
			productid: user.params.productid
		}
	}) as {
		class_record: Array<{}>;
		teacher: Array<{}>
	};
	render(fd, {
		d: d.class_record,
		img: d.teacher[0],
		teacher: user.params.teacher_name,
		time: date_time
	});
}
